<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex applyInvoic_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between flex-sub applyInvoic_fd0_0'>
					<view class='flex align-center applyInvoic_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  applyInvoic_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text class='applyInvoic_fd0_0_c1_c0'>申请开票</text>
					</view>
					<view class='flex align-center applyInvoic_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout applyInvoic_flex_1">
				<view class='flex flex-direction align-stretch applyInvoic_fd1_0'>
					<view class='flex flex-wrap align-center justify-between applyInvoic_fd1_0_c0'>
						<text class='applyInvoic_fd1_0_c0_c0'>发票类型</text>
						<text class='applyInvoic_fd1_0_c0_c1'>电子发票</text>
					</view>
					<view class='flex flex-wrap align-center justify-between applyInvoic_fd1_0_c1'>
						<text>发票信息</text>
						<text>{{invoice_type?'商品详情':'服务详情'}}</text>
					</view>
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c2'>
						<text class='applyInvoic_fd1_0_c2_c0'>抬头类型</text>
						<benben-select-diy ref="showSelectPopup1689756647721" class-name='flex align-center flex'
							:items.sync="type" v-model="billInfo.header_type" default-type="value" default-label="name"
							:allow-cancel='false' type="radio" :disabled='false'>
							<template v-for='(item,key0) in type'>
								<view v-if="item.isSelected" class='flex align-center flex applyInvoic_fd1_0_c2_c1_c0'
									:key="key0" @tap="$refs.showSelectPopup1689756647721.tapHandle(key0)">
									<image class='applyInvoic_fd1_0_c2_c1_c0_c0' mode="aspectFit"
										:src='STATIC_URL+"133.png"'></image>
									<text class='applyInvoic_fd1_0_c0_c1'>{{item.name}}</text>
								</view>
								<view v-else class='flex align-center flex applyInvoic_fd1_0_c2_c1_c0' :key="key0"
									@tap="$refs.showSelectPopup1689756647721.tapHandle(key0)">
									<image class='applyInvoic_fd1_0_c2_c1_c0_c0' mode="aspectFit"
										:src='STATIC_URL+"81.png"'></image>
									<text class='applyInvoic_fd1_0_c0_c1'>{{item.name}}</text>
								</view>
							</template></benben-select-diy>
					</view>
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c3'>
						<image class='applyInvoic_fd1_0_c4_c0' mode="aspectFit" :src='STATIC_URL+"526.png"'></image>
						<text class='applyInvoic_fd1_0_c3_c0'>发票抬头</text>
						<benben-input class='flex-sub applyInvoic_fd1_0_c3_c1' type="text" :placeholder="`请输入发票抬头`"
							confirm-type="done" :maxlength="50" placeholder-style="color:#BFBFBF;font-size:32rpx"
							v-model="billInfo.name" />
					</view>
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c3' v-if="billInfo.header_type=='2'">
						<image class='applyInvoic_fd1_0_c4_c0' mode="aspectFit" :src='STATIC_URL+"526.png"'></image>
						<text class='applyInvoic_fd1_0_c4_c1'>公司税号</text>
						<benben-input class='flex-sub applyInvoic_fd1_0_c3_c1' type="text" :placeholder="`请输入企业单位税号`"
							confirm-type="done" :maxlength="20" placeholder-style="color:#BFBFBF;font-size:32rpx"
							v-model="billInfo.duty_number" />
					</view>
					<!--     <view   class='flex flex-wrap align-center justify-between applyInvoic_fd1_0_c0'      >
        <text class='applyInvoic_fd1_0_c0_c0'  >设置为默认抬头</text>
        <benben-flex-switch-new class-name='flex flex'  v-model="is_tk" :disabled='false'   >
            <template v-slot:checked>
            
    <view   class='flex flex position-relative align-center'      >
        <image class='applyInvoic_checkfd1_0_c5_c1_c0_c0'  mode="aspectFit"  :src='STATIC_URL+"527.png"'></image>
</view>

            </template>
            <template v-slot:unchecked>
            
    <view   class='flex flex position-relative justify-end align-center'      >
        <image class='applyInvoic_noCheckfd1_0_c5_c1_c1_c0'  mode="aspectFit"  :src='STATIC_URL+"528.png"'></image>
</view>

            </template>
        </benben-flex-switch-new>
</view>
 -->
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c6'>
					</view>
					<!--     <view   class='flex flex-wrap align-center justify-between applyInvoic_fd1_0_c0'      >
        <text class='applyInvoic_fd1_0_c0_c0'  >发票内容</text>
<text class='applyInvoic_fd1_0_c0_c1'  >商品明细</text>
</view>
 -->
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c6'>
					</view>
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c3'>
						<image class='applyInvoic_fd1_0_c4_c0' mode="aspectFit" :src='STATIC_URL+"526.png"'></image>
						<text class='applyInvoic_fd1_0_c4_c1'>联系方式</text>
						<benben-input class='flex-sub applyInvoic_fd1_0_c3_c1' type="number" :placeholder="`请输入联系方式`"
							confirm-type="done" :maxlength="11" placeholder-style="color:#BFBFBF;font-size:32rpx"
							v-model="billInfo.drawer_mobile" />
					</view>
					<view class='flex flex-wrap align-center applyInvoic_fd1_0_c3'>
						<image class='applyInvoic_fd1_0_c4_c0' mode="aspectFit" :src='STATIC_URL+"526.png"'></image>
						<text class='applyInvoic_fd1_0_c4_c1'>电子邮箱</text>
						<benben-input class='flex-sub applyInvoic_fd1_0_c3_c1' type="text" :placeholder="`请输入电子邮箱`"
							confirm-type="done" :maxlength="32" placeholder-style="color:#BFBFBF;font-size:32rpx"
							v-model="billInfo.email" />
					</view>
				</view>
				<view class='flex flex-wrap align-center justify-center applyInvoic_fd1_1'>
					<button class='applyInvoic_fd1_1_c0' @tap.stop="submitFunc()">提交</button>
				</view>
			</view>




		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"type": [{
					"name": "个人",
					"value": "1",
					"image": ""
				}, {
					"name": "企业",
					"value": "2",
					"image": ""
				}],
				"is_tk": false,
				"type_la": "",
				"billInfo": {
					"aid": "",
					"header_type": "1",
					"duty_number": "",
					"name": "",
					"bank": "",
					"drawer_mobile": "",
					"email": "",
					"tel": "",
					"address": "",
					"type": "",
					"card_number": "",
					"is_default": "",
					"status": ""
				},
				"order_sn": "",
				"invoice_type": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				order_sn,
				invoice_type
			} = options
			if (order_sn !== undefined) this.order_sn = order_sn
			if (invoice_type !== undefined) this.invoice_type = invoice_type
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//申请提交
			async submitFunc() {
				if (!validate(this.billInfo.name, 'require')) {
					this.$message.info('发票抬头不能为空');
					return false;
				}
				if (this.billInfo.header_type == 2) {
					if (!validate(this.billInfo.duty_number, 'require')) {
						this.$message.info('公司税号不能为空');
						return false;
					}
				}
				if (!validate(this.billInfo.drawer_mobile, 'require')) {
					this.$message.info('联系方式不能为空');
					return false;
				}
				if (!validate(this.billInfo.drawer_mobile, 'phone')) {
					this.$message.info('联系方式格式不正确');
					return false;
				}
				if (!validate(this.billInfo.email, 'require')) {
					this.$message.info('电子邮箱不能为空');
					return false;
				}
				if (!validate(this.billInfo.email, 'email')) {
					this.$message.info('电子邮箱格式不正确');
					return false;
				}
				//请求方法
				//数据验证

				let data637c73162162f = await this.$api.dbPost(global.apiUrls.post637c73162162f, {
					header_type: this.billInfo.header_type,
					type: '1',
					name: this.billInfo.name,
					duty_number: this.billInfo.duty_number,
					drawer_mobile: this.billInfo.drawer_mobile,
					email: this.billInfo.email,
					order_sn: this.order_sn,
					invoice_type: this.invoice_type
				});
				if (!data637c73162162f) return
				if (data637c73162162f.data.code != 1) {
					this.$message.info(data637c73162162f.data.msg);
					return
				}
				
				this.$message.info('提交成功');
				setTimeout(() => {
					uni.$emit('shenqingchengg')
					this.$urouter.navigateBack(1);
				}, 500)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.applyInvoic_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.applyInvoic_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.applyInvoic_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.applyInvoic_fd0_0_c0 {
		width: 180rpx;
	}

	.applyInvoic_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.applyInvoic_flex_1 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.applyInvoic_fd1_1_c0 {
		background: var(--benbenbgColor2);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}

	.applyInvoic_fd1_1 {
		position: fixed;
		left: 0rpx;
		bottom: calc(40rpx + var(--window-bottom));
		width: 750rpx;
	}

	.applyInvoic_fd1_0_c6 {
		background: rgba(248, 248, 248, 1);
		height: 20rpx;
		background-size: 100% auto !important;
	}

	.applyInvoic_noCheckfd1_0_c5_c1_c1_c0 {
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		width: 36rpx;
		height: 36rpx;
	}

	.applyInvoic_checkfd1_0_c5_c1_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}

	.applyInvoic_fd1_0_c4_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.applyInvoic_fd1_0_c4_c0 {
		width: 12rpx;
		height: 12rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.applyInvoic_fd1_0_c3_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
		text-align: right;
	}

	.applyInvoic_fd1_0_c3_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.applyInvoic_fd1_0_c3 {
		border-bottom: 1px solid #eee;
		margin: 0rpx 32rpx 0rpx 32rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.applyInvoic_fd1_0_c2_c1_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 18rpx 18rpx 18rpx 18rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.applyInvoic_fd1_0_c2_c1_c0 {
		margin: 0rpx 0rpx 0rpx 48rpx;
	}

	.applyInvoic_fd1_0_c2_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		margin: 0rpx auto 0rpx 0rpx;
	}

	.applyInvoic_fd1_0_c2 {
		border-bottom: 1px solid #eee;
		margin: 0rpx 32rpx 0rpx 32rpx;
		padding: 32rpx 0rpx 32rpx 20rpx;
	}

	.applyInvoic_fd1_0_c1 {
		background: rgba(253, 234, 235, 1);
		background-size: 100% auto !important;
		padding: 24rpx 52rpx 24rpx 52rpx;
		color: rgba(255, 0, 0, 1);
		font-weight: 700;
	}

	.applyInvoic_fd1_0_c0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.applyInvoic_fd1_0_c0_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.applyInvoic_fd1_0_c0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
		padding: 32rpx 0rpx 32rpx 20rpx;
	}

	.applyInvoic_fd1_0 {
		background: var(--benbenbgColor1);
		background-size: 100% auto !important;
		margin: 0rpx 0rpx 150rpx 0rpx;
	}
</style>